<?php
namespace app\logic;

use app\facade\Str;
use app\model\user\UserModel;
use Exception;

class UserLogic
{
    public function setPassword($uid, $password) {
        $user = UserModel::where("uid", $uid)->find();
        if ($user == null) {
            throw new Exception("用户不存在",1);
        }
        $user->password = Str::code($password, 'E', config("key.password"));
        $user->save();
        return true;
    }

    public function setInfo($uid, $data) {
        $j = json_encode($data);
        $u = UserModel::where("uid",$uid)->find();
        $u["content"] = $j;
        $u->save();
    }

    public function getInfo($uid) {
        $u = UserModel::where("uid",$uid)->find();
        return $u["content"];
    }
}